package org.nokatag.code;

public class RippleImageOp extends AbstractTransformImageOp
{

    protected double xWavelength;
    protected double yWavelength;
    protected double xAmplitude;
    protected double yAmplitude;
    protected double xRandom;
    protected double yRandom;

    public RippleImageOp()
    {
        xWavelength = 20D;
        yWavelength = 10D;
        xAmplitude = 5D;
        yAmplitude = 5D;
        xRandom = 5D * Math.random();
        yRandom = 5D * Math.random();
    }

    public double getxWavelength()
    {
        return xWavelength;
    }

    public void setxWavelength(double xWavelength)
    {
        this.xWavelength = xWavelength;
    }

    public double getyWavelength()
    {
        return yWavelength;
    }

    public void setyWavelength(double yWavelength)
    {
        this.yWavelength = yWavelength;
    }

    public double getxAmplitude()
    {
        return xAmplitude;
    }

    public void setxAmplitude(double xAmplitude)
    {
        this.xAmplitude = xAmplitude;
    }

    public double getyAmplitude()
    {
        return yAmplitude;
    }

    public void setyAmplitude(double yAmplitude)
    {
        this.yAmplitude = yAmplitude;
    }

    protected void transform(int x, int y, double t[])
    {
        double tx = Math.sin((double)y / yWavelength + yRandom);
        double ty = Math.cos((double)x / xWavelength + xRandom);
        t[0] = (double)x + xAmplitude * tx;
        t[1] = (double)y + yAmplitude * ty;
    }
}

